package com.gmzg.gmzgoffice.message;


import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;

import com.gmzg.gmzgoffice.R;
import com.hyphenate.chat.EMConversation;
import com.hyphenate.easeui.ui.EaseConversationListFragment;

/**
 * A simple {@link Fragment} subclass.
 */
public class MessageFragment extends Fragment implements EaseConversationListFragment.EaseConversationListItemClickListener {


    public MessageFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View ret = inflater.inflate(R.layout.fragment_message, container, false);
        EaseConversationListFragment fragment = new EaseConversationListFragment();
        fragment.setConversationListItemClickListener(this);

        FragmentManager manager = getChildFragmentManager();
        FragmentTransaction tx = manager.beginTransaction();
        tx.replace(R.id.conversation_fragment_container, fragment);
        tx.commit();
        return ret;
    }

    @Override
    public void onListItemClicked(EMConversation conversation) {
        Intent intent = new Intent(getContext(), ChatActivity.class);
        String userName = conversation.getUserName();
        intent.putExtra("toUserName", userName);
        startActivity(intent);
    }
}
